import http from '../utils/http.js'
import axios from 'axios'

  //查询所有作者数据
function showAllmedal(val) {
    return http({
        method: 'post',
        url: '/admin/medal/showMedalByPage',
        params:{
            page:val,
            limit:1000
        }
    })
}  
// 通过勋章名称模糊查询作者信息数据
function showTagByMedalName(params){
    return http({
        method: 'post',
        url: '/admin/medal/showTagByMedalName',
        params:{
            ...params,
            page:1,
            limit:1000
            
        }
    })
}


// 添加或修改勋章
function addOrUpdateMedal(params){
    return http({
        method: 'post',
        url: '/admin/medal/addOrUpdateMedal',
        params:{
            ...params
        }
    })
}
// 上传头像
function uploadMedalImage(file){
    console.log('file',file)
   return  axios({
        method: 'post',
        url: 'http://42.192.83.237:8080/admin/content/uploadContentImage',
        headers: {
            "Content-Type": "multipart/form-data",
            token:sessionStorage.getItem('token')
        },
        data: {
            mpFile:file
        }
    })
}
// 批量修改勋章状态
function updateMedalState(params,str){
    return http({
        method: 'post',
        url: '/admin/medal/updateMedalState',
        params:{
            ids:[...params],
            state:str
        }
    })
}

// 删除勋章
function deleteMedal(params){
    return http({
        method: 'post',
        url: '/admin/medal/deleteMedal',
        params:{ids:[...params]}
    })
}

//获取所有内容数据
function showAllcontent(val) {
    return http({
        method: 'post',
        url: '/admin/content/showContentByPage',
        params:{
            page:val,
            limit:1000
        }
    })
}  
// 条件模糊查询内容数据
function showContentBycontentName(params){
    return http({
        method: 'post',
        url: '/admin/content/showContentByCondition',
        params:{
            ...params,
            
        }
    })
}
//获取所有商品数据
function showAllGoods(val) {
    return http({
        method: 'get',
        url: '/portal/goods/showGoodsPage',
        params:{
            page:val,
            limit:1000
        }
    })
}  
// 条件模糊查询商品数据
function showGoodsByGoodsName(params){
    return http({
        method: 'post',
        url: '/portal/goods/showGoods',
        params:{
            ...params,
            
        }
    })
}
export {
    showAllmedal,
    showTagByMedalName,
    uploadMedalImage,
    addOrUpdateMedal,
    updateMedalState,
    deleteMedal,
    showAllcontent, 
    showContentBycontentName,
    showAllGoods,
    showGoodsByGoodsName
}